package com.atguigu.gmall.activity.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @author: atguigu
 * @create: 2023-05-13 14:47
 */
@Configuration
public class CaffineeCacheConfig {

    /**
     * 秒杀商品状态本地缓存对象
     * @return
     */
    @Bean
    public Cache<String, String> seckillCache() {
        return Caffeine.newBuilder()
                .expireAfterWrite(24, TimeUnit.HOURS)
                .maximumSize(500)
                .build();
    }

}
